<template>
	<view class="content mainpadding2">
		<u-navbar title="提領" placeholder autoBack>
			<view class="flexright xiaohei" slot="right" @click="goAddBankCard">
				<view class="toprightbtn">
					添加銀行帳戶
				</view>
			</view>
		</u-navbar>
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 100rpx;"></view>
		</view>
		<view class="bankCard margin_top" v-for="item in list.data" :key="item.id" @click="selectBankFn(item)">
			<view class="flexleft">
				<view class="color_ling text_b margin_right2" style="font-size: 36rpx;">{{item.bank}}
				</view>
			</view>
			<view class="flexbetween margin_top1">
				<view class="num">{{item.num}}</view>
				<view class="flexleft">
					<image class="imgBox margin_right2" src="@/static/image/system/bankEdit.png" mode=""
						@click="edititem(item.id)"></image>
					<image class="imgBox" src="@/static/image/system/bankDelete.png" @click="delBanke(item.id)" mode="">
					</image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: {
					data: []
				},
				type: 0
			}
		},
		onLoad(options) {
			if (options.type) {
				this.type = options.type
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			selectBankFn(item) {
				if (this.type == 1) {
					uni.$emit("seleckBank", item)
					uni.navigateBack(1)
				}
			},
			init() {
				this.http.request('/api/shop/listBanke', 'POST', {
					shop_id: uni.getStorageSync("shop_id"),
				}).then(res => {
					if (res.code == 1) {
						this.list.data = res.data
					} else {
						this.list.data = []
					}
				})
			},
			delBanke(id) {
				this.http.modal('提示', '是否確認刪除？', true, (resp) => {
					if (resp) {
						this.http.request('/api/shop/delBanke', 'POST', {
							id
						}).then(res => {
							if (res.code == 1) {
								this.init()
							} else {
								this.http.toast(res.msg)
							}
						})
					}
				})

			},
			goAddBankCard() { //添加银行卡
				uni.navigateTo({
					url: "/pages/workbench/tianjiayhk"
				})
			},
			edititem(id) {
				uni.navigateTo({
					url: "/pages/workbench/tianjiayhk?id=" + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding-bottom: 150rpx;
	}

	.bankCard {
		border-radius: 12rpx 12rpx 12rpx 12rpx;
		border: 2rpx solid #FFE195;
		padding: 20rpx;

		.num {
			font-size: 30rpx;
			font-family: DIN Next LT Pro-Medium, DIN Next LT Pro;
			font-weight: 500;
			color: #000000;
		}

		.line {
			width: 0;
			height: 16rpx;
			border-right: 1rpx solid #999999;
		}

		.name {
			font-size: 24rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFB800;
		}

		.imgBox {
			width: 49rpx;
			height: 49rpx;
		}
	}
	.toprightbtn {
		background-color: #FFB800;
		color: #333;
		font-size: 24rpx;
		font-weight: 900;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		letter-spacing: 3rpx;
	}
</style>